package org.microframework.base.core.log.config;

import org.microframework.base.core.log.aspect.LogAspect;
import org.microframework.base.core.log.service.AsyncLogService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志配置
 */
@Configuration
@EnableAsync
@EnableConfigurationProperties(LogProperties.class)
public class LogAutoConfiguration {
    
    /**
     * 操作日志记录处理
     */
    @Bean
    @ConditionalOnProperty(value = "log.enabled", havingValue = "true", matchIfMissing = true)
    public LogAspect logAspect() {
        return new LogAspect();
    }
    
    /**
     * 异步日志服务
     */
    @Bean
    @ConditionalOnProperty(value = "log.async", havingValue = "true", matchIfMissing = true)
    public AsyncLogService asyncLogService() {
        return new AsyncLogService();
    }
} 